import toast from '../toast/index.js'
import { Http } from './http.js'
import BASE_CONFIG from '../../../globalConfig'

// 平台调用接口对象
export const http = new Http({
  // 基础URL
  baseURL: BASE_CONFIG.pathURL,
  // 超时设置
  timeout: BASE_CONFIG.timeout,
  // 拦截请求
  requestHandle (config) {
    // console.log(config, '拦截请求')
    // const uuid = sessionStorage.getItem('uuid')
    // const uuid = '88888'
    // if (uuid) {
    //   config.headers.tnControl = JSON.stringify({
    //     uuid: uuid
    //   })
    // }

    return config
  },
  // 响应拦截
  responseHandle (response) {
    if (response.status >= 500) {
      toast('网路错误，请寻找管理员')
    }

    return response
  }

})
